﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="role_edit.aspx.cs" Inherits="ByteSite.Web.admin.manager.role_edit" ValidateRequest="false" %>
<%@ Import namespace="ByteSite.Common" %>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑角色</title>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="stylesheet" type="text/css" href="../../scripts/artdialog/ui-dialog.css" />

<link rel="stylesheet" type="text/css" href="../skin/default/style.css" />
<link href="../skin/uikit/css/uikit.min.css" rel="stylesheet" />
<script type="text/javascript" src="../skin/uikit/js/uikit.min.js"></script>
<script type="text/javascript" src="../skin/uikit/js/uikit-icons.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../scripts/jquery/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../scripts/jquery/Validform_v5.3.2_min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../scripts/artdialog/dialog-plus-min.js"></script>
<script type="text/javascript" src="../../scripts/xm-select/xm-select.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/common.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/laymain.js"></script>
<style type="text/css">
    .layer {
    display:inline-block;
    }
    .layer-2 {
        width:15px;
    }
    .layer-3 {
        width:30px;
    }
    .layer-4 {
        width:45px;
    }
    .layer-5 {
        width:60px;
    }
    .layer-6 {
        width:75px;
    }
    .layer-7 {
        width:90px;
    }
    .layer-8 {
        width:105px;
    }
    .layer-9 {
        width:120px;
    }
    .layer-10 {
        width:135px;
    }
</style>
<script type="text/javascript">
    $(function () {
        //初始化表单验证
        $("#form1").initValidform();

        //是否启用权限
        if ($("#ddlRoleType").find("option:selected").attr("value") == 1) {
            $(".tree-list").find("input[type='checkbox']").prop("disabled", true);
        }
        $("#ddlRoleType").change(function () {
            if ($(this).find("option:selected").attr("value") == 1) {
                $(".tree-list").find("input[type='checkbox']").prop("checked", false);
                $(".tree-list").find("input[type='checkbox']").prop("disabled", true);
            } else {
                $(".tree-list").find("input[type='checkbox']").prop("disabled", false);
            }
        });
        //权限全选
        $("input[name='checkAll']").click(function () {
            if ($(this).prop("checked") == true) {
                $(this).parent().siblings(".col").find("input[type='checkbox']").prop("checked", true);
            } else {
                $(this).parent().siblings(".col").find("input[type='checkbox']").prop("checked", false);
            }
        });
    });
    function toggleChildren(id) {
        console.log($("#toggle-" + id).attr("class"));
        if ($("#toggle-" + id).hasClass("uk-icon-down")) {
            $("#list tbody tr").each(function (index, obj) {
                console.log(index);
                if ($(this).attr("parent") == id) {
                    $(this).hide();
                }
            })
            $("#toggle-" + id).removeClass("uk-icon-down").addClass("uk-icon-right");
            $("#toggle-" + id).attr("uk-icon", "chevron-right");
        } else if ($("#toggle-" + id).hasClass("uk-icon-right")) {
            $("#list tbody tr").each(function (index, obj) {
                console.log(index);
                if ($(this).attr("parent") == id) {
                    $(this).show();
                }
            })
            $("#toggle-" + id).removeClass("uk-icon-right").addClass("uk-icon-down");
            $("#toggle-" + id).attr("uk-icon", "chevron-down");
        }
    }
</script>
</head>

<body class="mainbody">
<form id="form1" runat="server">


<!--内容-->

      <ul uk-tab>
        <li class="uk-active"><a class="" href="javascript:;">编辑角色信息</a></li>
      </ul>


<div class="tab-content">
  <dl>
    <dt>角色类型</dt>
    <dd>
      <div class="rule-single-select">
        <asp:DropDownList id="ddlRoleType" runat="server" CssClass="uk-select" datatype="*" errormsg="请选择角色类型！" sucmsg=" "></asp:DropDownList>
      </div>
    </dd>
  </dl>
  <dl>
    <dt>角色名称</dt>
    <dd><asp:TextBox ID="txtRoleName" runat="server" CssClass="uk-input" datatype="*1-100" sucmsg=" "></asp:TextBox> <span class="Validform_checktip">*角色中文名称，100字符内</span></dd>
  </dl>   
  <dl>
    <dt>管理权限</dt>
    <dd>

        <div class="uk-overflow-auto tree-list">
            <table id="list" class="uk-table uk-table-striped uk-table-hover uk-table-middle uk-table-divider">
                <thead>
                    <tr>
                        <th class="uk-table-expand">导航名称</th>
                        <th class="uk-table-expand">权限分配</th>
                        <th class="uk-table-expand">全选</th>

                    </tr>
                </thead>
                <tbody>
                    <asp:Repeater ID="rptList" runat="server" onitemdatabound="rptList_ItemDataBound">
                    <ItemTemplate>
                    <tr parent="<%#Eval("parent_id")%>">
                        <td>
                            <asp:HiddenField ID="hidName" Value='<%#Eval("name") %>' runat="server" />
                            <asp:HiddenField ID="hidActionType" Value='<%#Eval("action_type") %>' runat="server" />
                            <span class="layer layer-<%#Eval("class_layer")%>"></span>
                            <a id="toggle-<%#Eval("id")%>" class="uk-icon-down" uk-icon="chevron-down" onclick="toggleChildren('<%#Eval("id")%>')"></a>
                            <%#Eval("title")%> <%#Eval("name")%>
                        </td>
                        <td>
                            <div class="rule-multi-porp">
                                <asp:CheckBoxList ID="cblActionType" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" CssClass="cbllist"></asp:CheckBoxList>
                            </div>
                        </td>
                        <td>
                            <input name="checkAll" type="checkbox" class="uk-checkbox" />
                        </td>
                    </tr>
                    </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
        </div>

    </dd>
  </dl>
</div>
<!--/内容-->

<!--工具栏-->
<div class="page-footer">
  <div class="btn-wrap">
    <asp:Button ID="btnSubmit" runat="server" Text="提交保存" CssClass="uk-button uk-button-primary " onclick="btnSubmit_Click" />
    <input name="btnReturn" type="button" value="取消返回" class="uk-button uk-button-default " onclick="javascript:history.back(-1);" />
  </div>
</div>
<!--/工具栏-->

</form>
</body>
</html>
